/**
 * @Desc 全局过滤器
 */
import { tranNumber } from '@/utils/array.js';
const dateFormat = function (value, format) {
    if (!value) return value;

  const date = new Date(value.replace(/-/g, '/'));
  if (/(y+)/.test(format)) {
    format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
  }

  const o = {
    'M+': date.getMonth() + 1,
    'd+': date.getDate(),
    'h+': date.getHours(),
    'm+': date.getMinutes(),
    's+': date.getSeconds()
  };
  for (const k in o) {
    if (new RegExp(`(${k})`).test(format)) {
      const str = o[k] + '';
      format = format.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str));
    }
  }
  return format;
  },
  transformHotNum = function (value, num) {
    if (!value) return value;
    return tranNumber(value, num);
  };
  function padLeftZero (str) {
    return ('00' + str).substr(str.length);
  }
export default {
  dateFormat,
  transformHotNum
};
